package command.example;

import command.Command;
import command.example.cmd.CloseDoor;
import command.example.cmd.OpenDoor;
import command.example.cmd.SetChannel;
import command.example.cmd.SetVolume;
import command.example.cmd.TurnOffLight;
import command.example.cmd.TurnOffTV;
import command.example.cmd.TurnOnLight;
import command.example.cmd.TurnOnTV;
import command.example.receiver.Door;
import command.example.receiver.Light;
import command.example.receiver.TV;

// 测试命令模式

public class Test {
	
	public static void main(String[] args) {
		// 门，灯，电视
		Door door = new Door();
		Light light = new Light();
		TV tv = new TV();
		
		// 遥控器
		RemoteControl remoteControl = new RemoteControl();
		
		// 一些命令
		Command[] commands = {
				new OpenDoor(door),  // 开门
				new TurnOnLight(light), // 开灯
				new CloseDoor(door), // 关门
				new TurnOnTV(tv), // 开电视
				new SetVolume(tv, 10), // 设定音量
				new SetChannel(tv, 1), // 设定频道
				new TurnOffTV(tv), // 关电视
				new TurnOffLight(light), // 关灯
		};
		
		// 用遥控器执行以上命令
		for (Command command : commands) {
			remoteControl.setCommand(command);
			remoteControl.buttonPressed();
		}
	}

}
